﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DLMemberPointMS.Entity.POCOModel;
using DLMemberPointMS.Common;
using DLMemberPointMS.Entity.ViewModel;

namespace DLMemberPointMS.Business
{
    public class CardLevelsService:BaseService<CardLevels>
    {
        public OperateResult GetData(CardLevelsViewModel mod)
        {
            var query = PredicateExtensions.True<CardLevels>();
            //拼接条件
            if (!string.IsNullOrEmpty(mod.CL_LevelName))
            {
                query = query.And(c => c.CL_LevelName.Contains( mod.CL_LevelName));
            }
            if (mod.CL_ID > 0)
            {
                query = query.And(c => c.CL_ID== mod.CL_ID);
            }
            //数据的行数
            int count = 0;
            var datas = GetList(mod.page, mod.limit, ref count, query, c => c.CL_ID, true).Select(c => new
            {
                c.CL_ID,
                c.CL_LevelName,
                c.CL_NeedPoint,
                c.CL_Percent,
                c.CL_Point
            });
            return new OperateResult(code.Success, "ok", datas, count);
        }
    }
}
